#include <Arduino.h>
#include "Button.h"
#include "WatchDog.h"
#include "Menu_Ctrl.h"
#include "WS2812B.h"

/*全局变量*/
extern uint8_t machine_rest_flag;

void setup() 
{
  // put your setup code here, to run once:
  Serial.begin(115200);
  delay(10);

  Serial.printf("main.cpp %d:ESP32 HEAP:%d\r\n",__LINE__,esp_get_free_heap_size());

  Button_Init();

  Serial.printf("main.cpp %d:ESP32 HEAP:%d\r\n",__LINE__,esp_get_free_heap_size());

  WS2812B_Init();

  Serial.printf("main.cpp %d:ESP32 HEAP:%d\r\n",__LINE__,esp_get_free_heap_size());

  WatchDog_Init();

  Serial.printf("main.cpp %d:ESP32 HEAP:%d\r\n",__LINE__,esp_get_free_heap_size());

  Serial.println("loop start");
}

void loop() 
{
  // put your main code here, to run repeatedly:
  Feed_Dog();

  uint8_t button_state = Get_Button_State();
  if(button_state != 0)
  {
    Serial.printf("Button ESP32 HEAP1 %d\r\n", esp_get_free_heap_size());
    Serial.printf("button %d\r\n", button_state);
  }

  menu_proc(button_state);

  if(machine_rest_flag != MACHINE_CLOSE)
  {
    
  }

  Feed_Dog();
}